package com.songtech.server.frame.route;

/**
 * Create By YINN on 2018/4/7 0:22
 * Description : 路由实现
 */

import com.songtech.server.entry.BaseProtocal;
import com.songtech.server.entry.ConfirmProtocal;
import com.songtech.server.frame.BaseServiceRegister;
import com.songtech.server.frame.service.BaseService;
import org.springframework.stereotype.Service;

import java.time.LocalTime;

@Service
public class RouteImpl implements Route {

//    @Override
//    public void dispense(String manufacturer, String imei, String cmd, LocalTime cmdTime, String[] cmdParam) {
//
//        BaseService service = BaseServiceRegister.getService(cmd);
//
//        service.invoke(manufacturer, imei, cmd, cmdTime, cmdParam);
//    }

    @Override
    public void dispense(BaseProtocal baseProtocal) {

        BaseService service = BaseServiceRegister.getService(baseProtocal.getCmd());

        System.out.println(service + "。imei:" + baseProtocal.getImei());

        service.invoke(baseProtocal);
    }

    @Override
    public void confirm(ConfirmProtocal entry) {

        BaseService service = BaseServiceRegister.getService(entry.getCmd());

        System.out.println(service);

        service.invoke(entry);

    }
}
